<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>在线答题</title>
    <link rel="stylesheet" href="/static/exam/layui/css/layui.css">
    <script src="/static/exam/js/jquery.js"></script>
    <script src="/static/exam/js/layer.js"></script>
    <script>
        $.get('{:url("exam/common/check")}',function(data){
            if(data == '0'){
                alert("请先登录！")
                window.location.href='{:url("exam/login/homeLogin")}'
            }else{
                $('#navname').text(data.name)
            }
        },"json")
        function quit() {
            layer.confirm('您确定要退出系统吗？', function (index) {
                $.get("{:url('exam/login/out')}",function (result) {
                    if (result == true){
                        window.location.href = "{:url('exam/login/homeLogin')}"
                    }
                })
            })
        }

        function editPwd() {
            var pwd = $('#pwd').val()
            var repwd = $('#repwd').val()
            if (pwd == ''){
                layer.alert('密码不能为空',{
                    icon: 2,
                    skin: 'layer-ext-moon'
                })
            }else if (repwd == ''){
                layer.alert('确认密码不能为空',{
                    icon: 2,
                    skin: 'layer-ext-moon'
                })
            }else if (pwd.length > 20){
                layer.alert('密码不能超过20位',{
                    icon: 2,
                    skin: 'layer-ext-moon'
                })
            } else if (repwd != pwd){
                layer.alert('密码与确认密码不一致',{
                    icon: 2,
                    skin: 'layer-ext-moon'
                })
            }else {
               
                $.post("{:url('exam/login/editpwd')}",{password:pwd},function (result) {
                    if (result > 0){
                        layer.alert('修改成功！',{
                            icon: 6,
                            skin: 'layer-ext-moon'
                        })
                        updToggle()
                        window.location.href = "{:url('exam/login/homeLogin')}"
                    }else {
                        layer.alert('修改失败！',{
                            icon: 5,
                            skin: 'layer-ext-moon'
                        })
                    }
                })
            }
        }
    </script>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">在线考试系统</div>

        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" id="navname"></li>
            <li class="layui-nav-item"><a onclick="updToggle()" href="javascript:;">修改密码</a></li>
            <li class="layui-nav-item"><a onclick="quit()" href="javascript:;">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree"  lay-filter="test">
            {if ($Think.session.userdata.type==1)}
                <li class="layui-nav-item"><a href="{:url('exam/user/index')}" target="myframe">用户管理</a></li>
                <li class="layui-nav-item"><a href="{:url('exam/question/question')}" target="myframe">题库管理</a></li>
                <li class="layui-nav-item"><a href="{:url('exam/paper/paper')}" target="myframe">试卷管理</a></li>
                <li class="layui-nav-item"><a href="{:url('exam/paper/adspaperlist')}" target="myframe">历史试卷管理</a></li>



            {else/}
                 <li class="layui-nav-item"><a href="{:url('exam/onlinetest/index')}" target="myframe">在线考试</a></li>
                 <li class="layui-nav-item"><a href="{:url('exam/paper/upaper')}" target="myframe">试卷记录</a></li>
                

            {/if}
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;width: 100%;height: 100%">
            <iframe src="{:url('exam/index/content')}" name="myframe" frameborder="0" class="layadmin-iframe" width="100%" height="100%"></iframe>
        </div>

    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © xsj
    </div>
</div>
<!--修改密码-->
<div style='display:none;width:460px;height:211px;z-index:1000;position: fixed;top: 50%;left: 50%;background-color: #fff;
    box-shadow: 2px 0px 20px 0px;margin-top: -146px;margin-left: -250px;' id='update'>
    <div class="layui-layer-title">修改密码</div>
    <span class="layui-layer-setwin"><a class="layui-layer-ico layui-layer-close layui-layer-close1" href="javascript:;"
                                        onclick='updToggle()'></a></span>
    <div style='padding-right: 10px;padding-top: 10px'>
        <div class='layui-form-item'>
            <label class='layui-form-label'><span style='color:red'>*</span>密码</label>
            <div class='layui-input-block'>
                <input type='password' lay-verify='title' autocomplete='off' placeholder='不超过20位'
                       class='layui-input' id='pwd'>
            </div>
        </div>
        <div class='layui-form-item'>
            <label class='layui-form-label'><span style='color:red'>*</span>确认密码</label>
            <div class='layui-input-block'>
                <input type='password' lay-verify='title' autocomplete='off' placeholder='不超过20位'
                       class='layui-input' id='repwd'>
            </div>
        </div>

        <button type="button" class='layui-btn layui-btn-primary' style='float: right;' onclick='updToggle()'>取消</button>
        <button type="button" class='layui-btn layui-btn-normal' style='float: right;margin-right: 10px' onclick='editPwd()'>保存
        </button>
    </div>
</div>
<div class="layui-layer-shade" id="layui-layer-shade1" times="1" style="z-index: 999;display: none; background-color: rgb(0, 0, 0); opacity: 0.3;"></div>
<script src="/static/exam/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use('element', function(){
        var element = layui.element;

    });
    function updToggle() {
        $("#update").fadeToggle("slow")
        $("#layui-layer-shade1").fadeToggle()
    }
</script>
</body>
</html>